/*
* Slider (Refactored)@VERSION
*
* Copyright XXXX, COPYRIGHT HOLDERS
*
* Depends:
* 
*/

var API = API || {};

API.x_slider = {
    SliderManager: function(pager_holder, slider_id, list_row) {
		var parent = this;
	
    	// Filter constants
    	var sliderScrollTime = 1300;
		
		// References
		var pager_holder = pager_holder;
		var slider_id = slider_id;
		var list_row = list_row;

    	this.effects_manager = new API.x_effects.EffectsManager();
    	this.effects_manager.Init(list_row, pager_holder);
		
		this.UIValue = function(value) {
	
	        switch (value) {
	            case 0:
	                return 0;
	            case 50:
	                return 100;
	            case 100:
	                return 300;
	            case 150:
	                return 500;
	            case 200:
	                return 1000;
	        }
	
	    };
		
		this.Init = function(doFilter) {
			parent.doFilter = doFilter;

			$(slider_id).slider({
	            animate: true,
	            range: "min",
	            value: 0,
	            min: 0,
	            max: 200,
	            step: 50,
	            change: parent.Change
	
	        });
	    };
	
	    this.Change = function(event, ui) {
			if(is_filtering == true){
				event.stopPropagation();

				return false;
			} else {
				is_filtering = true;
			}
	        var data_id = $(this).attr('data-id');

	        parent.effects_manager.preEffects();

	        var value = parent.UIValue(ui.value);
	        $("#" + data_id).html(value);

	        parent.effects_manager.afterEffects(parent.doFilter, [data_id, value, value]);
	    };
    }
};
